home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************/
- /* */
- /* rj.c 06/19/86 */
- /* */
- /* this program sends a command line to another network */
- /* station for remote execution. The other network station */
- /* must be running rjexec. A message will be returned and */
- /* printed on the bottome line when the remote job is complete. */
- /* */
- /* rev 1.1 07/11/86 recompile to use revised semopen call */
- /* */
- /****************************************************************/
-
- #include <string.h>
- #include "novell.h"
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int user_no;
- int result, value, users;
- unsigned long handle;
- char station[64];
- int i;
- char cmnd_line[128], message[128];
- long ltime, target_time;
- char c;
-
- printf("Remote job submission program -- Ver. 1.1\n");
- printf("For Novell Netware\n");
- printf("Copyright (c) 1986 -- Ken Hales\n\n");
-
- /********************************************************/
- /* make sure there is a command to send */
- /********************************************************/
-
- if (argc < 2) {
- printf("Usage: rj <command line>\n");
- exit(1);
- }
-
- /********************************************************/
- /* find out who is running rjexec */
- /********************************************************/
-
- result = semopen("rj", 0, &handle, &users);
-
- if (result != 0) {
- printf("Problem opening semaphore: %d\n", result);
- printf("Program aborted\n");
- exit(1);
- }
-
- if (users < 2) {
- printf("No workstation is currently running rjexec.\n");
- printf("Program aborted\n");
- semclose(handle);
- exit(1);
- }
-
- result = semexam(handle, &value, &users);
-
- if (result != 0) {
- printf("Problem examining semaphore: %d\n", result);
- printf("Program aborted\n");
- semclose(handle);
- exit(1);
- }
-
- /********************************************************/
- /* open a message pipe to the remote job workstation */
- /********************************************************/
-
- station[0] = value;
- pipopen(1, station);
-
- /********************************************************/
- /* send command to the remote job workstation by */
- /* writing to its message pipe. */
- /********************************************************/
-
- strcpy(message, argv[1]);
- for (i=2; i<argc; i++) {
- strcat(message, " ");
- strcat(message, argv[i]);
- }
-
- station[0] = value;
- pipwrite(1, station, message);
-
- if (station[0] != 0) {
- printf("Not successful.\n");
- printf("Remote workstation queue is probably full.\n");
- result = 1;
- } else {
- printf("Job has been successfully sent to remote workstation.\n");
- result = 0;
- }
-
- /********************************************************/
- /* done - close semaphore and pipe, then exit */
- /********************************************************/
-
- station[0] = value;
- pipclose(1, station);
- semclose(handle);
- exit(result);
- }